package com.ibl.rover.lite.common.bean;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

public class CustomerBean extends BaseBean {

	@ColumnOrder(Order = 1)
	private String code;
	@ColumnOrder(Order = 2)
	private String name;
	@ColumnOrder(Order = 3)
	private String address;
	@ColumnOrder(Order = 4)
	private double creditLimit;
	@ColumnOrder(Order = 5)
	private int routeNumber;
	@ColumnOrder(Order = 6)
	private int position;

	private static AutomatedQueryStatement AUTO_GEN_QUERY;

	public static final String COL_CODE	 = "CODE";
	public static final String COL_NAME = "NAME";
	public static final String COL_ADDRESS = "ADDRESS";
	public static final String COL_CREDIT_LIMIT = "CREDIT_LIMIT";
	public static final String COL_ROUTE_NUMBER = "ROUTE_NUMBER";
	public static final String COL_POSITION = "POSITION";

	public static final int IDX_COL_CODE = 1;
	public static final int IDX_COL_NAME = 2;
	public static final int IDX_COL_ADDRESS = 3;
	public static final int IDX_COL_CREDIT_LIMIT = 4;
	public static final int IDX_COL_ROUTE_NUMBER = 5;
	public static final int IDX_COL_POSITION = 6;

	static {
		AUTO_GEN_QUERY = SQLiteDatabaseHelper
				.getAutoGeneratedStmts(CustomerBean.class);
	}

	public CustomerBean() {

	}

	@Override
	public void bind(SQLiteStatement sqlLiteStatement) {
		sqlLiteStatement.bindString(IDX_COL_CODE, code);
		sqlLiteStatement.bindString(IDX_COL_NAME, name);
		sqlLiteStatement.bindString(IDX_COL_ADDRESS, address);
		sqlLiteStatement.bindDouble(IDX_COL_CREDIT_LIMIT, creditLimit);
		sqlLiteStatement.bindLong(IDX_COL_ROUTE_NUMBER, routeNumber);
		sqlLiteStatement.bindLong(IDX_COL_POSITION,position);
	}

	@Override
	public <T extends BaseBean> T cursorBind(Cursor cursor) {
		CustomerBean customerBean = new CustomerBean();
		customerBean.set_id(cursor.getInt(IDX_COL_ID));
		customerBean.setCode(cursor.getString(IDX_COL_CODE));
		customerBean.setName(cursor.getString(IDX_COL_NAME));
		customerBean.setAddress(cursor.getString(IDX_COL_ADDRESS));
		customerBean.setCreditLimit(cursor.getDouble(IDX_COL_CREDIT_LIMIT));
		customerBean.setRouteNumber(cursor.getInt(IDX_COL_ROUTE_NUMBER));
		customerBean.setPosition(cursor.getInt(IDX_COL_POSITION));
		return (T) customerBean;
	}

	@Override
	public <T extends BaseBean> T cursorInit(Cursor cursor) {
		this.set_id(cursor.getInt(IDX_COL_ID));
		this.setCode(cursor.getString(IDX_COL_CODE));
		this.setName(cursor.getString(IDX_COL_NAME));
		this.setAddress(cursor.getString(IDX_COL_ADDRESS));
		this.setCreditLimit(cursor.getDouble(IDX_COL_CREDIT_LIMIT));
		this.setRouteNumber(cursor.getInt(IDX_COL_ROUTE_NUMBER));
		this.setPosition(cursor.getInt(IDX_COL_POSITION));
		return (T) this;
	}

	@Override
	public String getCreateTableQuery() {

		return AUTO_GEN_QUERY.getCreateTableQuery();
	}

	@Override
	public String getInsertQuery() {

		return AUTO_GEN_QUERY.getPreparedInsertQuery();
	}

	@Override
	public String getDeleteQuery() {

		return AUTO_GEN_QUERY.getPreparedDeleteQuery();
	}

	@Override
	public String getUpdateQuery() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTableName() {

		return AUTO_GEN_QUERY.getTableName();
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}



	public double getCreditLimit() {
		return creditLimit;
	}

	public void setCreditLimit(double creditLimit) {
		this.creditLimit = creditLimit;
	}

	public int getRouteNumber() {
		return routeNumber;
	}

	public void setRouteNumber(int routeNumber) {
		this.routeNumber = routeNumber;
	}

	@Override
	public ContentValues bindContentValues() {
		// TODO Auto-generated method stub
		return null;
	}

	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}

	
}
